package ex2.trans;

import java.util.NoSuchElementException;

import ex2.Employee;
import ex2.PayrollDatabase;
import ex2.Transaction;
import ex2.exception.NoSuchEmployeeException;

public abstract class ChangeEmployeeTransaction implements Transaction {
    private int empId;

    public ChangeEmployeeTransaction(int empId) {
        this.empId = empId;
    }

    @Override
    public void execute() {
        Employee e = PayrollDatabase.getEmployee(empId);
        if (e == null) {
            throw new NoSuchEmployeeException();
        }
        doChange(e);
    }

    protected abstract void doChange(Employee e);

}
